﻿<template>
    <div class="hidden h100 flex-column">
        <component is="style" />
            <div class="flex-row padding-tb-8">
                <el-form :inline="true" :model="query" size="small" class="demo-form-inline margin-left-8 flex-row-fill">
                    <el-form-item label="名称">
                        <el-input v-model="query.fileName" placeholder="请输入名称" clearable></el-input>
                    </el-form-item>                    
                    <el-form-item>
                        <el-button type="primary" v-on:click="loadList">查询</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <div class="flex-column-fill hidden">
                <vxe-table :data="list" ref="vxeTable" stripe border style="width:100%;" height="100%" size="small" auto-resize :row-config="{isCurrent: true, isHover: true}" :column-config="{minWidth:'60px'}" show-header-overflow show-overflow>
                    <vxe-column field="fileName" width="250" align="center" fixed="left" title="文件名称">
                        <template #default="d">
                            <el-link type="primary" :underline="false" v-on:click="open(d.row.fileFullName)">
                                {{d.row.fileName}}
                            </el-link>
                        </template>
                    </vxe-column>
                    <vxe-column min-width="250" header-align="center" show-overflow-tooltip title="文件路径">                        
                        <template #default="d">
                            <span>{{d.row.fileFullName}}</span>
                        </template>
                    </vxe-column>
                    <vxe-column field="fileCreationTime" title="创建时间" width="150" align="center"></vxe-column>
                    <vxe-column field="fileLastWriteTime" title="修改时间" width="150" align="center"></vxe-column>
                    <vxe-column field="fileLength" title="文件大小" width="100" align="center"></vxe-column>
                    
                    @*<vxe-column title="操作" width="120" align="center" fixed="right">
                        <template #default="scope">
                            <el-button type="text" size="small"
                                       :disabled="scope.row.biStatus!=0||scope.row.openId!=optor.openId"
                                       v-on:click="add(1,scope.row.biId)">退换</el-button>
                            <el-button v-on:click="deleteRow(scope.$index,scope.row)"
                                       :disabled="!optor.root&&scope.row.openId!=optor.openId" type="text" size="small">
                                删除
                            </el-button>
                        </template>
                    </vxe-column>*@
                </vxe-table>
            </div>
        </div>
</template>
<script>
    module = (function (hxt) {
        return {
            name: 'proc',
            props: {

            },
            data: function () {
                var _this = this, optor = hxt.store.optor;
                return {
                    optor: optor,
                    list: [],
                    query: {
                        fileName:''
                    },
                }
            },
            computed: {

            },
            watch: {

            },
            activated: function () {
            },
            mounted: function () {
                var _this = this;
                _this.loadList();
            },
            methods: {
                loadList: function () {
                    var _this = this;
                    hxt.post({
                        url: hxt.config.link + 'file/getSQLScriptList',
                        data: { fileName: _this.query.fileName},
                        ok: function (res) {
                            if (res.code != 0) return hxt.error('加载列表失败：' + res.errmsg);
                            _this.list = res.data;
                        }
                    });
                },
                open: function (fileFullName) {
                    var _this = this;
                    var textarea = document.createElement('textarea');
                    textarea.style.position = 'fixed';
                    textarea.style.opacity = 0;
                    textarea.value = fileFullName;
                    document.body.appendChild(textarea);
                    textarea.select();
                    document.execCommand('copy');
                    document.body.removeChild(textarea);
                    hxt.success('复制成功');

                    hxt.post({
                        url: hxt.config.link + 'file/openFile',
                        data: { fileFullName: fileFullName },
                        ok: function (res) {
                            if (res.code != 0) return hxt.error('打开文件失败：' + res.errmsg);
                        }
                    });
                },
                
            },
            components: {
            }
        };
    })(window.$jscript.fn);
</script>
<style>
    .el-tab-pane {
        height: 100%;
    }

    .el-tabs__content {
        flex: 1;
    }

    .el-tabs--border-card > .el-tabs__content {
        padding: 0px !important;
    }
</style>